<template>
  <div>
    <h2>基础使用示例</h2>
    <p>展示ScreenAdapter组件的基本用法</p>

    <!-- 示例1：最简单的用法 -->
    <div class="example-section">
      <h3>1. 最简单的用法</h3>
      <ScreenAdapter>
        <div class="basic-content">
          <h1>欢迎使用 ScreenAdapter</h1>
          <p>这是一个基础的大屏适配示例</p>
          <div class="stats">
            <div class="stat-item">
              <div class="stat-value">1,234</div>
              <div class="stat-label">用户数量</div>
            </div>
            <div class="stat-item">
              <div class="stat-value">5,678</div>
              <div class="stat-label">访问量</div>
            </div>
            <div class="stat-item">
              <div class="stat-value">90.5%</div>
              <div class="stat-label">成功率</div>
            </div>
          </div>
        </div>
      </ScreenAdapter>
    </div>

    <!-- 示例2：不同适配模式 -->
    <div class="example-section">
      <h3>2. 适配模式对比</h3>
      <div class="mode-controls">
        <button
          v-for="mode in modes"
          :key="mode"
          @click="currentMode = mode"
          :class="{ active: currentMode === mode }"
          class="mode-btn"
        >
          {{ mode.toUpperCase() }}
        </button>
      </div>

      <ScreenAdapter :mode="currentMode" :design-width="800" :design-height="600">
        <div class="mode-demo-content">
          <h2>适配模式: {{ currentMode.toUpperCase() }}</h2>
          <div class="demo-grid">
            <div class="demo-card" v-for="i in 6" :key="i">
              <h4>卡片 {{ i }}</h4>
              <p>模式: {{ currentMode }}</p>
              <div class="demo-chart">
                <div class="chart-bar" :style="{ height: Math.random() * 80 + 20 + '%' }"></div>
              </div>
            </div>
          </div>
        </div>
      </ScreenAdapter>
    </div>

    <!-- 示例3：调试模式 -->
    <div class="example-section">
      <h3>3. 调试模式</h3>
      <label>
        <input type="checkbox" v-model="debugMode" />
        开启调试模式
      </label>

      <ScreenAdapter :debug="debugMode" debug-position="top-left">
        <div class="debug-content">
          <h2>调试模式演示</h2>
          <p>调试模式可以显示当前的适配信息</p>
          <div class="debug-info">
            <p>✨ 开启调试模式后，左上角会显示调试面板</p>
            <p>🔧 包含设计尺寸、当前窗口、缩放比例等信息</p>
            <p>📱 可以帮助开发者调试适配效果</p>
          </div>
        </div>
      </ScreenAdapter>
    </div>
  </div>
</template>

<script>
import ScreenAdapter from "../index.vue";

export default {
  name: "BasicExample",
  components: {
    ScreenAdapter,
  },
  data() {
    return {
      modes: ["scale", "fit", "full"],
      currentMode: "fit",
      debugMode: false,
    };
  },
};
</script>

<style lang="less" scoped>
.example-section {
  margin: 40px 0;
  padding: 20px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;

  h3 {
    margin-top: 0;
    color: #303133;
  }
}

.mode-controls {
  margin: 16px 0;
  display: flex;
  gap: 8px;

  .mode-btn {
    padding: 8px 16px;
    border: 1px solid #dcdfe6;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      border-color: #409eff;
      color: #409eff;
    }

    &.active {
      background: #409eff;
      border-color: #409eff;
      color: white;
    }
  }
}

// 基础内容样式
.basic-content {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;

  h1 {
    margin: 0 0 20px 0;
    font-size: 48px;
    font-weight: 600;
  }

  p {
    margin: 0 0 40px 0;
    font-size: 18px;
    opacity: 0.9;
  }

  .stats {
    display: flex;
    gap: 40px;

    .stat-item {
      .stat-value {
        font-size: 32px;
        font-weight: bold;
        margin-bottom: 8px;
      }

      .stat-label {
        font-size: 14px;
        opacity: 0.8;
      }
    }
  }
}

// 模式演示内容样式
.mode-demo-content {
  width: 100%;
  height: 100%;
  background: #f5f7fa;
  padding: 20px;

  h2 {
    text-align: center;
    margin: 0 0 20px 0;
    color: #303133;
  }

  .demo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;
    height: calc(100% - 60px);

    .demo-card {
      background: white;
      border-radius: 8px;
      padding: 16px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      display: flex;
      flex-direction: column;

      h4 {
        margin: 0 0 8px 0;
        color: #303133;
      }

      p {
        margin: 0 0 auto 0;
        color: #606266;
        font-size: 14px;
      }

      .demo-chart {
        height: 40px;
        display: flex;
        align-items: flex-end;
        padding-left: 8px;

        .chart-bar {
          width: 20px;
          background: linear-gradient(to top, #409eff, #66b1ff);
          border-radius: 2px 2px 0 0;
          transition: height 0.8s ease;
        }
      }
    }
  }
}

// 调试内容样式
.debug-content {
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;

  h2 {
    margin: 0 0 20px 0;
    font-size: 36px;
  }

  p {
    margin: 0 0 20px 0;
    font-size: 16px;
  }

  .debug-info {
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 8px;
    text-align: left;

    p {
      margin: 8px 0;
      font-size: 14px;
      line-height: 1.6;
    }
  }
}

// 响应式
@media screen and (max-width: 768px) {
  .mode-controls {
    flex-wrap: wrap;
  }

  .demo-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }

  .basic-content {
    .stats {
      flex-direction: column;
      gap: 20px;
    }
  }
}
</style>
